from digits import sumOfDigits

def sqrt(n, nrdigits):
    p = 0
    c = n
    
    while p < 10 ** (nrdigits - 1):
        for x in xrange(0, 10):
            if (20 * p + x) * x > c:
                x -= 1
                break;
            
        c -= (20 * p + x) * x
        c *= 100
        
        p = 10 * p + x

    return p

print sum([sumOfDigits(sqrt(n, 100)) for x in xrange(1, 11) for n in xrange((x-1)**2 + 1, x**2)])
    
    